package com.tianqu.tms.www.car.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.TmsAjaxAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.exception.TmsException;
import com.tianqu.tms.dto.MarketCarInfoDto;
import com.tianqu.tms.dto.TmsMarketCarFinancialDto;
import com.tianqu.tms.dto.TmsMarketCarFinancialParam;
import com.tianqu.tms.entity.Car;
import com.tianqu.tms.entity.TmsFinancial;

import net.sf.json.JSONObject;

public class MarketCarFinancialAjaxAction extends TmsAjaxAction {
	@Override
	public void process(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response, UserContext uc) throws TmsException {
		String vin = (String) uc.getParameter("vin");
		//
		List<MarketCarInfoDto> list = Car.getInstance().findCarListByVin(vin);
		JSONObject json = new JSONObject();
		if (list.size() > 0) {
			MarketCarInfoDto dto = list.get(0);
			json.put("tempLicensePlate", dto.getTempLicensePlate());
			json.put("licensePlate", dto.getLicensePlate());
		}else {
			json.put("tempLicensePlate","");
			json.put("licensePlate", "");
		}
		responseValues(response, json.toString(), TEXT);
	}
}
